import { UserProfilesAPI } from '@/request/api'
export default {
    namespaced: true,
    state: {
        // 购物车
        cartTotal: 0,
        //用户信息
        userInfo: {
            headImg: require("../../assets/img/userImg.f8bbec5e.png"),
            //昵称
            nickName: "---",
            //积分
            coin: 0
        },
    },
    getters: {
    },
    mutations: {
        changeUserInfo(state, payload) {
            state.cartTotal = payload.cartTotal
            state.userInfo = payload.userInfo
        },
         // 初始化用户信息
         initUserInfo(state){
            state.cartTotal = 0
            state.userInfo={
                 //头像
                 headImg: require('../../assets/img/userImg.f8bbec5e.png'),
                 //昵称
                 nickName: '---',
                 // 积分 鸡腿数
                 coin:0
             }
         }
    },
    actions: {
        async asyncUserInfo({ commit }) {
            let res = await UserProfilesAPI()
            console.log("用户信息res:",res.data);
            commit('changeUserInfo', res.data)
        }
    },
    modules: {
    }
}